#include "turtle.hpp"
#include "utils.hpp"


TurtState::TurtState(double x, double y, double angle):
    pos(x, y), angle(angle)
{ }

TurtState::TurtState(const FVector2d &pos, double angle):
    pos(pos), angle(angle)
{ }


Turtle::Turtle(double x, double y, double angle):
    state(x, y, angle)
{ }

Turtle::Turtle(const FVector2d &pos, double angle):
    state(pos, angle)
{ }
 

Turtle::Turtle(const TurtState &start):
    state(start)
{ }


void Turtle::forward(double step)
{
    state.pos.x += step * degcos(state.angle);
    state.pos.y += step * degsin(state.angle);
}


void Turtle::turn_left(double deg)
{
    state.angle += deg;
}


void Turtle::turn_right(double deg)
{
    state.angle -= deg;
}

void Turtle::remember(void)
{
    _pos_stack.push(state);
}


void Turtle::restore(void)
{
    state = _pos_stack.top();
    _pos_stack.pop();
}
